/*
 * @Author: 陆成杰
 * @Date: 2022-06-23 14:34:04
 * @LastEditTime: 2022-07-02 23:07:02
 * @LastEditors: 陆成杰
 * @FilePath: /boe/src/route/index.ts
 * Copyright (c) ${now_year} by zucc-陆成杰, All Rights Reserved. 
 */
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'


const routes:Array<RouteRecordRaw> = [

  // tabbar及其子路由
  {
    path: "",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: ()=> import('../views/login/Login.vue')
  },
  {
    path: "/publish",
    name: "Publish",
    component: ()=> import('../views/program-manager/Pulish.vue')
  },
  {
    path: "/publishh",
    name: "PublishH",
    component: ()=> import('../views/program-manager/PulishH.vue')
  },
  {
    path: "/layout",
    name: "Layout",
    component: ()=> import('../layout/Layout.vue'),
    redirect: "/home",
    children: [
    {
      path: "/home",
      name: "Home",
      component: ()=> import('../views/home/Home.vue')
    },
    {
      path: "/devicelist",
      name: "DeviceList",
      component: ()=> import('../views/device-manager/DeviceList.vue')
    },
    {
      path: "/teammanager",
      name: "TeamManager",
      component: ()=> import('../views/device-manager/TeamManager.vue')
    },
    {
      path: "/material",
      name: "Material",
      component: ()=> import('../views/material-manager/Material.vue')
    },
    {
      path: "/planexamin",
      name: "PlanExamin",
      component: ()=> import('../views/plan-manager/PlanExamin.vue')
    },
    {
      path: "/planlist",
      name: "PlanList",
      component: ()=> import('../views/plan-manager/PlanList.vue')
    },
    {
      path: "/newplan",
      name: "NewPlan",
      component: ()=> import('../views/plan-manager/NewPlan.vue')
    },
    {
      path: "/planequipment",
      name: "PlanEquipment",
      component: ()=> import('../views/plan-manager/PlanEquipment.vue')
    },
    {
      path: "/publishnotice",
      name: "PublicNotice",
      component: ()=> import('../views/program-manager/PublishNotice.vue')
    },
    {
      path: "/publishprogram",
      name: "PublishProgram",
      component: ()=> import('../views/program-manager/PublishProgram.vue')
    },
    {
      path: "/accountmanager",
      name: "AccountManager",
      component: ()=> import('../views/system-manager/AccountManager.vue')
    },
    {
      path: "/notice",
      name: "Notice",
      component: ()=> import('../views/program-manager/Notice.vue')
    }
  ]
  },
  
  
  

]

const router = createRouter({
  history:createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  if(to.path == '/login'){
    return next()
  }

  const tokenstr = window.localStorage.getItem('token')
  if(!tokenstr){
    return next('/login')
  }else{
    next()
  }

})

export default router